package com.hhit.bigscreenbackmanage.controller.jdgl;

import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.service.jdgl.JdglService;
import com.hhit.bigscreenbackmanage.service.jdgl.TJdglDwjsjdjhService;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/jdglController")
public class JdglController {

    private static Logger log = LoggerFactory.getLogger(JdglController.class);

    @Autowired
    private TJdglDwjsjdjhService tJdglDwjsjdjhService;

    @Autowired
    private JdglService jdglService;

    /**
     * 查询电网建设进度计划
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryDwjsjdjh")
    public Response queryDwjsjdjh(@RequestBody JSONObject jsonObject) {
        try {
            Map<String, Object> stringObjectMap = tJdglDwjsjdjhService.queryDwjsjdjh(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 查询各地市农民工工资
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryGdsnmggz")
    public Response queryGdsnmggz(@RequestBody JSONObject jsonObject) {
        try {
            Map<String, Object> stringObjectMap = tJdglDwjsjdjhService.queryGdsnmggz(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 开工投产输变电个数
     * @return
     */
    @PostMapping("/queryKgTcSbdCount")
    public Response queryKgTcSbdCount() {
        try {
            Map<String, Object> stringObjectMap = tJdglDwjsjdjhService.queryKgTcSbdCount();
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        } catch (Exception e) {
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 开工投产输变详情
     * @return
     */
    @PostMapping("/queryKgTcSbdXq")
    public Response queryKgTcSbdXq(@RequestBody JSONObject jsonObject) {
        try {
            Map<String, Object> stringObjectMap = tJdglDwjsjdjhService.queryKgTcSbdXq(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        } catch (Exception e) {
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 上个月开工投产--变电
     * @return
     */
    @PostMapping("/queryLastMonthBd")
    public Response queryLastMonthBd() {
        try {
            Map<String, Object> stringObjectMap = tJdglDwjsjdjhService.queryLastMonthBd();
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        } catch (Exception e) {
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }

    }

    /**
     * 上个月开工投产--线路
     * @return
     */
    @PostMapping("/queryLastMonthXl")
    public Response queryLastMonthXl() {
        try {
            Map<String, Object> stringObjectMap = tJdglDwjsjdjhService.queryLastMonthXl();
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        } catch (Exception e) {
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }


    /**
     * 当月开工投产计划
     * @return
     */
    @PostMapping("/queryCurrentMonthKgTc")
    public Response queryCurrentMonthKgTc() {
        try {
            Map<String, Object> stringObjectMap = tJdglDwjsjdjhService.queryCurrentMonthKgTc();
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        } catch (Exception e) {
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 截至月底各地市公司综合计划完成情况
     * @return
     */
    @PostMapping("/queryGdsgszhjhwcqk")
    public Response queryGdsgszhjhwcqk(@RequestBody Map map) {
        try {
            Map<String, Object> stringObjectMap = jdglService.queryGdsgszhjhwcqk(map);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        } catch (Exception e) {
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * @Description: 获取待办预警一览 (进度预警)
     * @Return:
     **/
    @GetMapping("/getProgressWarningByJdYj")
    public Response<Map<String, Object>> getProgressWarningByJdYj(@Param("status") String status,
                                                                  @Param("cityCode") String cityCode,
                                                                  @Param("pageSize") String pageSize,
                                                                  @Param("pageNo") String pageNo){
        try {
            Map<String, Object> outBean = tJdglDwjsjdjhService.
                    getProgressWarning("JDYJ",status,cityCode,pageSize,pageNo);
            return Response.createResponseBySuccess("查询成功",outBean);
        }catch (Exception e){
            log.error("getProgressWarningByJdYj Call error",e);
            return Response.createResponseByError("查询失败:"+ e.getMessage());
        }
    }

    /**
     * @Description: 获取待办预警一览 (物资预警)
     * @Param: [map]
     * @Return:
     **/
    @GetMapping("/getProgressWarningByWz")
    public Response<Map<String, Object>> getProgressWarningByEAQWTHZ(@Param("status") String status,
                                                                     @Param("cityCode") String cityCode,
                                                                     @Param("pageSize") String pageSize,
                                                                     @Param("pageNo") String pageNo){
        try {
            Map<String, Object> outBean = tJdglDwjsjdjhService.getProgressWarning("WZ",
                    status,cityCode,pageSize,pageNo);
            return Response.createResponseBySuccess("查询成功",outBean);
        }catch (Exception e){
            log.error("getProgressWarningByEAQWTHZ Call error",e);
            return Response.createResponseByError("查询失败:"+ e.getMessage());
        }
    }

    /**
     * 预警统计总览
     * @param cityCode
     * @return
     */
    @GetMapping("/getWarningTotal")
    public Response<Map<String, Object>> getWarningTotal(@Param("cityCode") String cityCode,@Param("modelType") String modelType) {
        try {
            Map<String, Object> warningTotal = tJdglDwjsjdjhService.getWarningTotal(cityCode, modelType);
            return Response.createResponseBySuccess("操作成功",warningTotal);
        }catch (Exception e){
            log.error("getWarningTotal Call error",e);
            return Response.createResponseByError("操作失败:"+ e.getMessage());
        }
    }

    /**
     * 获取物资上报情况分析统计
     * @return
     */
    @GetMapping("/getMaterialReportingAnalysisCount")
    public Response<Map<String, Object>> getMaterialReportingAnalysisCount(@Param("cityCode") String cityCode) {
        try {
            Map<String, Object> outBean = tJdglDwjsjdjhService.getMaterialReportingAnalysisCount(cityCode);
            return Response.createResponseBySuccess("操作成功",outBean);
        }catch (Exception e){
            log.error("getMaterialReportingAnalysisCount Call error",e);
            return Response.createResponseByError("操作失败:"+ e.getMessage());
        }
    }

    /**
     * 重点工程统计
     * @return
     */
    @GetMapping("/getZdgctj")
    public Response<Map<String, Object>> getZdgctj() {
        try {
            Map<String, Object> outBean = tJdglDwjsjdjhService.getZdgctj();
            return Response.createResponseBySuccess("操作成功",outBean);
        }catch (Exception e){
            log.error("getMaterialReportingAnalysisCount Call error",e);
            return Response.createResponseByError("操作失败:"+ e.getMessage());
        }
    }

    /**
     * 超长工期统计
     * @return
     */
    @GetMapping("/queryCcgqTj")
    public Response queryCcgqTj() {
        try {
            Map<String, Object> outBean = tJdglDwjsjdjhService.queryCcgqTj();
            return Response.createResponseBySuccess("操作成功",outBean);
        }catch (Exception e){
            log.error("getMaterialReportingAnalysisCount Call error",e);
            return Response.createResponseByError("操作失败:"+ e.getMessage());
        }

    }

    /**
     * 下月管理工作
     * @return
     */
    @GetMapping("/queryXyglgz")
    public Response queryXyglgz() {
        try {
            Map<String, Object> outBean = tJdglDwjsjdjhService.queryXyglgz();
            return Response.createResponseBySuccess("操作成功",outBean);
        }catch (Exception e){
            log.error("getMaterialReportingAnalysisCount Call error",e);
            return Response.createResponseByError("操作失败:"+ e.getMessage());
        }
    }

    /**
     * 查询停电计划
     * @return
     */
    @GetMapping("/queryPowerCutPlan")
    public Response queryPowerCutPlan(@Param("cityCode") String cityCode) {
        try {
            Map<String, Object> outBean = tJdglDwjsjdjhService.queryPowerCutPlan(cityCode);
            return Response.createResponseBySuccess("操作成功",outBean);
        }catch (Exception e){
            log.error("getMaterialReportingAnalysisCount Call error",e);
            return Response.createResponseByError("操作失败:"+ e.getMessage());
        }
    }

    /**
     * 获取年度进度计划-按数量统计
     *
     * @param
     * @return list
     */
    @RequestMapping("/getNdjdjhasltj")
    public List<Map<String, Object>> getNdjdjhasltj(@RequestParam Map map) {
        try {
            List<Map<String, Object>> list = jdglService.getNdjdjhasltj(map);
            return  list;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 获取年度进度计划-按规模统计
     *
     * @param
     * @return list
     */
    @RequestMapping("/getNdjdjhagmtj")
    public List<Map<String, Object>> getNdjdjhagmtj(@RequestParam Map map) {
        try {
            List<Map<String, Object>> list = jdglService.getNdjdjhagmtj(map);
            return  list;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取累计开工情况
     *
     * @param
     * @return list
     */
    @RequestMapping("/getLjkgqk")
    public List<Map<String, Object>> getLjkgqk(@RequestParam Map map) {
        try {
            List<Map<String, Object>> list = jdglService.getLjkgqk(map);
            return  list;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 获取累计投产情况
     *
     * @param
     * @return list
     */
    @RequestMapping("/getLjtcqk")
    public List<Map<String, Object>> getLjtcqk(@RequestParam Map map) {
        try {
            List<Map<String, Object>> list = jdglService.getLjtcqk(map);
            return  list;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     *截止上月底进度完成情况（因换表重写）
     * @return
     */
    @GetMapping("/searchJzsydjdwcqkData")
    public Response searchJzsydjdwcqkData() {
        try {
            Map<String, Object> outBean = jdglService.searchJzsydjdwcqkData();
            return Response.createResponseBySuccess("操作成功",outBean);
        }catch (Exception e){
            log.error("searchJzsydjdwcqkData Call error",e);
            return Response.createResponseByError("操作失败:"+ e.getMessage());
        }
    }

    /**
     *年度计划（因换表重写）
     * @param params
     * @return
     */
    @GetMapping("/queryNdjhData")
    public Response queryNdjhData(@RequestParam Map params) {
        try {
            Map<String, Object> outBean = jdglService.queryNdjhData(params);
            return Response.createResponseBySuccess("操作成功",outBean);
        }catch (Exception e){
            log.error("queryNdjhData Call error",e);
            return Response.createResponseByError("操作失败:"+ e.getMessage());
        }
    }
}
